package net.biodiversityatlas.utils
{
	import com.afcomponents.umap.overlays.Layer;
	import com.afcomponents.umap.overlays.Polyline;
	import com.afcomponents.umap.styles.GeometryStyle;
	import com.afcomponents.umap.types.LatLng;
	
	public class CellGrid extends Layer
	{
		public var gridStyle:GeometryStyle;
		
		public function CellGrid(resolution:Number=1)
		{
			
			//Default style for the grid
			gridStyle = new GeometryStyle();
			gridStyle.strokeRGB = 0x000000;
			gridStyle.strokeThickness = 1;
			gridStyle.strokeAlpha = .1;	
			
			//create the grid
			for (var i:Number = -85;i<=85;i++) {
        		var l:Object = new Object();
				l.points = new Array();
				l.points.push(new LatLng(i,-180));
				l.points.push(new LatLng(i,180));
			
				var lat:Polyline = new Polyline(l,this.gridStyle);
				this.addOverlay(lat);
        	}
        	
        	for (var j:Number = -180;j<=180;j++) {
        		var lo:Object = new Object();
				lo.points = new Array();
				lo.points.push(new LatLng(-85,j));
				lo.points.push(new LatLng(85,j));
			
				var lon:Polyline = new Polyline(lo,gridStyle);
				this.addOverlay(lon);
        	}  
			
		}

	}
}